<%--
  Created by IntelliJ IDEA.
  User: CY
  Date: 2018/5/16
  Time: 15:21
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%  String point=(String) request.getSession().getAttribute("coordinatePoint");%>
<html>
<head>
    <title>百度地图</title>
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=YECw4heQ9wzy7RKg8OW9QLMsySKzQRan"></script>
    <link rel="stylesheet" type="text/css" href="/css/street/street.css"/>
    <link rel="stylesheet" href="/css/officialDocument/officialDocument.css">
    <link rel="stylesheet" href="/css/base.css">
    <link rel="stylesheet" href="/lib/layer/skin/default/layer.css">
    <%--<script src="/js/street/TwoPointFive.js"></script>--%>
    <style>
        html{height:100%}
        body{height:100%;margin:0px;padding:0px}
        .head{height:50px}
        #map{width:100%;height:100%}
        .rightNav {
            position: fixed;
            top: 20%;
            right: 1%;
            width: 135px;
            height: 220px;
            z-index: 999;
            /*display: none;*/
        }
        .rightNav .one{
            background: url(/img/grid/btnxuanzhong.png) no-repeat;
            background-size: 100% 100%;
            -ms-behavior: url(/css/main/backgroundsize.min.htc);
            behavior: url(/css/main/backgroundsize.min.htc);
            width: 96%;
            height: 34px;
            line-height: 34px;
            margin-top: 10px;
            cursor: pointer;
            color: #fff;
            text-align: center;
            font-size: 14px;
        }
        .rightNav .one.active {
            background: url(/img/grid/activexuanzhong.png) no-repeat;
        }
        .rightNav .one:hover{
            background: url(/img/grid/activexuanzhong.png) no-repeat;
        }

        .qiye {
            position: fixed;
            top: 20%;
            left: 1%;
            width: 135px;
            height: 220px;
            z-index: 999;
            /*display: none;*/
        }
        .qiye .two{
            background: url(/img/grid/btnxuanzhong.png) no-repeat;
            background-size: 100% 100%;
            -ms-behavior: url(/css/main/backgroundsize.min.htc);
            behavior: url(/css/main/backgroundsize.min.htc);
            width: 96%;
            height: 34px;
            line-height: 34px;
            margin-top: 10px;
            cursor: pointer;
            color: #fff;
            text-align: center;
            font-size: 14px;
        }
        .qiye .two.active {
            background: url(/img/grid/activexuanzhong.png) no-repeat;
        }
        .qiye .two:hover{
            background: url(/img/grid/activexuanzhong.png) no-repeat;
        }
        .outer{
            width:26px;
            height:26px;
            position:absolute;
            background-size:100% ;
            z-index: 99999;
        }
        .inner{
            color:#fff;
            font-size:14px;
            display: inline-block;
            width:26px;
            text-align: center;
            position: relative;
            cursor:pointer;
            /*line-height: 36px;*/
            /*padding-left:40px;*/
            /*padding-top: 4px;*/
            /*word-break: break-all;*/
            /*text-overflow: ellipsis;*/
            /*display: -webkit-box; !** 对象作为伸缩盒子模型显示 **!*/
            /*-webkit-box-orient: vertical; !** 设置或检索伸缩盒对象的子元素的排列方式 **!*/
            /*-webkit-line-clamp: 1; !** 显示的行数 **!*/
            /*overflow: hidden;  !** 隐藏超出的内容 **!*/
        }
        .headImg{
            position: absolute;
            left: -37px;
            top: 0px;
        }
        .topName{
            display: inline-block;
            width: 80px;
            line-height: 30px;
            padding-left: 30px;
            text-align: left;
        }
        .botName{
            display: inline-block;
            width: 100px;
            line-height: 22px;
            padding-left: 30px;
            text-align: left;
        }

        .clearfx{
            width:100%;
            line-height: 50px;
            font-size:14px;
            /*height: 50px;*/
        }
        .cont{
            border-bottom: 1px dashed #eeeeee;
            width:80%;
            /*height:50px;*/
            /*margin-left: 40px;*/
            float:left
        }
        .left{
            /*width:30%;*/
            /*float:left;*/
            text-align: right;
            margin-left:3px;
        }
        .right{
            width:64%;
            /*float:left;*/
            text-align: left;
            margin-left:5%;
        }
        .img{
            float:left;
            vertical-align: middle;
            margin-top: 15px;
            margin-left:20px;
        }
    </style>
    <script src="/js/jquery/jquery-1.9.1.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/layer/layer.js?20201106" type="text/javascript" charset="utf-8"></script>
    <script src="/js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <%--<script type="text/javascript" src="/js/street/Library.js"></script>--%>
</head>
<body onload="maps.enterpriseMap('01')">
<%--<ul class="rightNav">--%>
    <%--<li class="one active" data-type="0">网格员地图</li>--%>
    <%--<li class="one" data-type="1">社区地图</li>--%>
    <%--<li class="one" data-type="2">网格地图</li>--%>
    <%--<li class="one" data-type="3">监控地图</li>--%>
    <%--<li class="one" data-type="4">企业地图</li>--%>
    <%--<li class="one" data-type="5">环保设施地图</li>--%>
<%--</ul>--%>
<ul class="qiye">
    <li class="two active" data-type="0">合格达标</li>
    <li class="two" data-type="1">一般隐患</li>
    <li class="two" data-type="2">突出隐患</li>
    <li class="two" data-type="3">重大隐患</li>
</ul>
<div id="map"></div>
<script>

    var map = new BMap.Map("map");
    //var point = new BMap.Point(118.019131,34.341107);
    var point = new BMap.Point(<%=point%>); //创建点坐标
    var map = new BMap.Map("map", {mapType: BMAP_HYBRID_MAP, minZoom: 1, maxZoom: 18});
    //设置地图类型及最小最大级别
    //    var marker = new BMap.Marker(point); //将点转化成标注点
    //    map.addOverlay(marker);  //将标注点添加到地图上
    map.addControl(new BMap.MapTypeControl({
        mapTypes:[
            BMAP_NORMAL_MAP,
            BMAP_HYBRID_MAP
        ]}));
    //设置地图级别（1-18）
    map.centerAndZoom(point, 12);
    //开启滚轮缩放地图
    map.enableScrollWheelZoom();

    //    绘制自定义覆盖物
    //    //        1\定义构造函数
    function ComplexCustomOverlay(point,img,name,id,con,grid,type,title){
        this._point = point;
        this._img = img;
        this._name = name;
        this._id = id;
        this._con = con;
        this._grid = grid;
        this._type = type;
        this._title = title;
    }
    // 继承API的BMap.Overlay
    ComplexCustomOverlay.prototype = new BMap.Overlay();
    //2、初始化自定义覆盖物实现初始化方法
    ComplexCustomOverlay.prototype.initialize = function(map){
        // 保存map对象实例
        this._map = map;
        // 创建div元素，作为自定义覆盖物的容器
        var div = this._div = document.createElement("div");
        div.style.backgroundImage = 'url('+this._img+')'
        div.setAttribute('class','outer');
        div.setAttribute('name',this._name);
        div.setAttribute('id',this._id);
        div.setAttribute('content',this._con);
        div.setAttribute('grid',this._grid);
        div.setAttribute('type',this._type);
        div.setAttribute('title',this._title);

        div.innerHTML= '<div class="inner">'+this._con+'</div>'
        // 将div添加到覆盖物容器中
        map.getPanes().labelPane.appendChild(div);
        //getPanes(),返回值:MapPane,返回地图覆盖物容器列表  labelPane呢???
        // 需要将div元素作为方法的返回值，当调用该覆盖物的show、
        // hide方法，或者对覆盖物进行移除时，API都将操作此元素。
        return div;
    }
    //3、绘制覆盖物
    // 实现绘制方法
    ComplexCustomOverlay.prototype.draw = function(){
        var _map = this._map;
//            var marker = new BMap.Marker(_map);
//            map.overlayPixelToPoint(this._point);
        var pixel = map.pointToOverlayPixel(this._point);
        this._div.style.left = pixel.x - 50 + "px";
        this._div.style.top  = pixel.y - 20 + "px";
    }

    //    nav点击事件
    $('.rightNav .one').click(function(){
        $(this).addClass('active').siblings().removeClass('active');
        $('.qiye').hide();
        if($(this).attr('data-type')==0){
            map.clearOverlays();
            maps.gridMap();
        }else if($(this).attr('data-type')==1){
            map.clearOverlays();
            maps.CommunityMap();
        }else if($(this).attr('data-type')==2){
            map.clearOverlays();
            maps.CommunityMap(maps.theGridMap);
        }else if($(this).attr('data-type')==3){
            map.clearOverlays();
            maps.monitorMap();
        }else if($(this).attr('data-type')==4){
            $('.qiye').show();
            map.clearOverlays();
            maps.enterpriseMap('01')
        }else if($(this).attr('data-type')==5){
            map.clearOverlays();
            maps.environmental()

        }
    })
    $('.qiye .two').click(function(){
        $(this).addClass('active').siblings().removeClass('active');
        if($(this).attr('data-type')==0){
            map.clearOverlays();
            maps.enterpriseMap('01')
        }else if($(this).attr('data-type')==1){
            map.clearOverlays();
            maps.enterpriseMap('02')
        }else if($(this).attr('data-type')==2){
            map.clearOverlays();
            maps.enterpriseMap('03')
        }else if($(this).attr('data-type')==3){
            map.clearOverlays();
            maps.enterpriseMap('04')
        }
    })

    function check(name){
        if(name == undefined){
            return ''
        }else{
            return name;
        }
    }

    $(document).on('click','.outer',function(){
        var type=$(this).attr('type');
        var id = $(this).attr('id');
        var name = $(this).attr('name');
        if(type == 1){
            $.get('/gridInfo/queryByUidMessage',{uid:id},function(res){
                var data= res.data;
                layer.open({
                    type:1,
                    title: ['网格员', 'background-color:#2b7fe0;color:#fff;'],
                    area: ['350px', '320px'],
                    btn: 0,
                    content:'<ul>' +
                    '<li class="clearfx"><img src="../../img/newsq.png" alt="" class="img"><div class="cont"><span class="left">姓名:</span><span class="right">'+check(data.userName) +'</span></div></li>' +
                    '<li class="clearfx"><img src="../../img/newsq.png" alt="" class="img"><div class="cont"><span class="left">联系方式:</span><span class="right">'+check(data.mobilNo) +'</span></div></li>' +
                    '<li class="clearfx"><img src="../../img/newlocation.png" alt="" class="img"><div class="cont"><span class="left">所属社区:</span><span class="right">'+check(data.infoName)+'</span></div></li>' +
                    '<li class="clearfx"><img src="../../img/newjgy.png" alt="" class="img"><div class="cont"><span class="left">位置:</span><span class="right">'+check(data.foot.location) +'</span></div></li>' +
                    '</ul>'
                })
            })
        }else if(type == 3){
            $.get('/fixForm/selectByListFixFromId',{type:name,fixFromId:id},function(res){
                var data= res.data;
                if(name==1){
                    layer.open({
                        type:1,
                        title: ['企业信息', 'background-color:#2b7fe0;color:#fff;'],
                        area: ['350px', '320px'],
                        btn: 0,
                        content:'<ul>' +
                        '<li class="clearfx"><img src="../../img/newsq.png" alt="" class="img"><div class="cont"><span class="left">企业名称:</span><span class="right">'+check(data.unitName) +'</span></div></li>' +
                        '<li class="clearfx"><img src="../../img/newsq.png" alt="" class="img"><div class="cont"><span class="left">联系方式:</span><span class="right">'+check(data.mobilePhone) +'</span></div></li>' +
                        '<li class="clearfx"><img src="../../img/newlocation.png" alt="" class="img"><div class="cont"><span class="left">负责人:</span><span class="right">'+check(data.legalRepresentative)+'</span></div></li>' +
                        '<li class="clearfx"><img src="../../img/newjgy.png" alt="" class="img"><div class="cont"><span class="left">位置:</span><span class="right">'+check(data.unitLocationArea) +'</span></div></li>' +
                        '</ul>'
                    })
                }else if(name==2){
                    layer.open({
                        type:1,
                        title: ['企业信息', 'background-color:#2b7fe0;color:#fff;'],
                        area: ['350px', '320px'],
                        btn: 0,
                        content:'<ul>' +
                        '<li class="clearfx"><img src="../../img/newsq.png" alt="" class="img"><div class="cont"><span class="left">企业名称:</span><span class="right">'+check(data.unitName) +'</span></div></li>' +
                        '<li class="clearfx"><img src="../../img/newsq.png" alt="" class="img"><div class="cont"><span class="left">联系方式:</span><span class="right">'+check(data.mobilePhone) +'</span></div></li>' +
                        '<li class="clearfx"><img src="../../img/newlocation.png" alt="" class="img"><div class="cont"><span class="left">负责人:</span><span class="right">'+check(data.legalRepresentative)+'</span></div></li>' +
                        '<li class="clearfx"><img src="../../img/newjgy.png" alt="" class="img"><div class="cont"><span class="left">位置:</span><span class="right">'+check(data.unitLocationArea) +'</span></div></li>' +
                        '</ul>'
                    })
                }else if(name==3){
                    layer.open({
                        type:1,
                        title: ['企业信息', 'background-color:#2b7fe0;color:#fff;'],
                        area: ['350px', '320px'],
                        btn: 0,
                        content:'<ul>' +
                        '<li class="clearfx"><img src="../../img/newsq.png" alt="" class="img"><div class="cont"><span class="left">企业名称:</span><span class="right">'+check(data.opName) +'</span></div></li>' +
                        '<li class="clearfx"><img src="../../img/newsq.png" alt="" class="img"><div class="cont"><span class="left">联系方式:</span><span class="right">'+check(data.mobPh) +'</span></div></li>' +
                        '<li class="clearfx"><img src="../../img/newlocation.png" alt="" class="img"><div class="cont"><span class="left">负责人:</span><span class="right">'+check(data.lightnDetect)+'</span></div></li>' +
                        '<li class="clearfx"><img src="../../img/newjgy.png" alt="" class="img"><div class="cont"><span class="left">位置:</span><span class="right">'+check(data.prAddress) +'</span></div></li>' +
                        '</ul>'
                    })
                }else if(name==4){
                    layer.open({
                        type:1,
                        title: ['企业信息', 'background-color:#2b7fe0;color:#fff;'],
                        area: ['350px', '320px'],
                        btn: 0,
                        content:'<ul>' +
                        '<li class="clearfx"><img src="../../img/newsq.png" alt="" class="img"><div class="cont"><span class="left">企业名称:</span><span class="right">'+check(data.opName) +'</span></div></li>' +
                        '<li class="clearfx"><img src="../../img/newsq.png" alt="" class="img"><div class="cont"><span class="left">联系方式:</span><span class="right">'+check(data.mobPh) +'</span></div></li>' +
                        '<li class="clearfx"><img src="../../img/newlocation.png" alt="" class="img"><div class="cont"><span class="left">负责人:</span><span class="right">'+check(data.lightnDetect)+'</span></div></li>' +
                        '<li class="clearfx"><img src="../../img/newjgy.png" alt="" class="img"><div class="cont"><span class="left">位置:</span><span class="right">'+check(data.prAddress) +'</span></div></li>' +
                        '</ul>'

                    })
                }else if(name==5){
                    layer.open({
                        type:1,
                        title: ['企业信息', 'background-color:#2b7fe0;color:#fff;'],
                        area: ['350px', '320px'],
                        btn: 0,
                        content:'<ul>' +
                        '<li class="clearfx"><img src="../../img/newsq.png" alt="" class="img"><div class="cont"><span class="left">企业名称:</span><span class="right">'+check(data.itemName) +'</span></div></li>' +
                        '<li class="clearfx"><img src="../../img/newsq.png" alt="" class="img"><div class="cont"><span class="left">联系方式:</span><span class="right">'+check(data.itemManagerno) +'</span></div></li>' +
                        '<li class="clearfx"><img src="../../img/newlocation.png" alt="" class="img"><div class="cont"><span class="left">负责人:</span><span class="right">'+check(data.itemManager)+'</span></div></li>' +
                        '<li class="clearfx"><img src="../../img/newjgy.png" alt="" class="img"><div class="cont"><span class="left">位置:</span><span class="right">'+check(data.gridName) +'</span></div></li>' +
                        '</ul>'

                    })
                }

            })
        }
    })



    var maps={
//        网格员地图
        gridMap:function(){
            var overlays = [];
            $.ajax({
                url:'/footprint/selectUserList',
                dataType:'json',
                success:function(res){
                    var data = res.obj;

                    for(var i=0;i<data.length;i++){
                        if(data[i].lng !="" && data[i].lat != ""){
                            overlays.push(data[i])
                        }
                    }
//                    console.log(overlays)
                    for(var j = 0;j<overlays.length;j++){

                        var lng = overlays[j].lng;
                        var lat = overlays[j].lat;
                        var point = new BMap.Point(lng,lat)
                        var Icon = '/img/grid/youcerenyuan.png';
                        var con = '<img class="headImg" src="'+function(){
                            if (overlays[j].users.sex == 1) {
                                return '/img/email/icon_head_man_06.png'
                            } else{
                                return '/img/email/icon_head_woman_06.png'
                            }
                        }()+'" alt=""><span class="topName">网格员</span> <span class="botName" title="'+overlays[j].users.name+'">'+overlays[j].users.name+'哈哈</span>'
                        //                        point,img,name,id,con,grid,type,title
                        var myCompOverlay = new ComplexCustomOverlay(point,Icon,overlays[j].users.name,overlays[j].uid ,con,'',1,overlays[j].users.name );
                        map.addOverlay(myCompOverlay);//将标注添加到地图中
                    }
                }
            })
        },
//        社区地图
        CommunityMap:function(fn){
            $.ajax({
                url:'/gridInfo/gridSettingsTree',
                dataType:'json',
                data:{
                    deptId:0,
                    typeId:0
                },
                success:function(res){
                    var data = res.obj;
                    for(var j=0;j<data.length;j++){
                        var mapInfo = res.obj[j].mapInfo;
                        if(mapInfo != undefined){
                            var arr = mapInfo.split('|');
//                        console.log(arr)
                            var poy = new BMap.Polygon(function(){
                                var arr2=[];
                                for(var i=0;i<arr.length;i++){
                                    var type =arr[i].split(',')
                                    var no=new BMap.Point(type[0],type[1]);
                                    arr2.push(no)
                                }
//                            console.log(arr2)
                                return arr2;
                            }(), {strokeColor:'#000',fillColor:'red', fillOpacity: 0.3,  strokeWeight:1, strokeOpacity:0.5});  //创建多边形
                            map.addOverlay(poy);
                            console.log(poy)
                            poy.title=data[j].gridName;
                            poy.tel=data[j].telNo;
                            poy.name=data[j].directorName;
                            poy.gridName=data[j].gridUserIdName;
                            poy.scope=data[j].scope;
                            poy.location=data[j].location;

                            poy.addEventListener('click',function(){
                                var title=this.title;
                                var tel=this.tel;
                                var name=this.name;
                                var gridName=this.gridName;
                                var scope=this.scope;
                                var location=this.location;

                                layer.open({
                                    type:1,
                                    title: [title, 'background-color:#2b7fe0;color:#fff;'],
                                    area: ['350px', '720px'],
                                    btn: 0,
                                    content:'<ul>' +
                                    '<li class="clearfx"><img src="/img/newjgy.png" alt="" class="img"><div class="cont"><span class="left">社区名称:</span><span class="right">'+check(title) +'</span></div></li>' +
                                    '<li class="clearfx"><img src="/img/newsq.png" alt="" class="img"><div class="cont"><span class="left">社区电话:</span><span class="right">'+check(tel)+'</span></div></li>' +
                                    '<li class="clearfx"><img src="/img/newjdy.png" alt="" class="img"><div class="cont"><span class="left">网格监督员:</span><span class="right">'+check(name) +'</span></div></li>' +
                                    '<li class="clearfx"><img src="/img/newjgy.png" alt="" class="img"><div class="cont"><span class="left">网格监管员:</span><span class="right">'+check(name) +'</span></div></li>' +
                                    '<li class="clearfx"><img src="/img/newxcy.png" alt="" class="img"><div class="cont"><span class="left">网格巡查员:</span><span class="right">'+check(gridName) +'</span></div></li>' +
                                    '<li class="clearfx"><img src="/img/newsq.png" alt="" class="img"><div class="cont"><span class="left">社区描述:</span><span class="right">'+check(scope) +'</span></div></li>' +
                                    '<li class="clearfx"><img src="/img/newlocation.png" alt="" class="img"><div class="cont"><span class="left">居委会位置:</span><span class="right">'+check(location) +'</span></div></li>' +
                                    '</ul>'
                                })
                            })
                        }
                    }

                }
            })
            if(fn){
                fn();
            }
        },

//        网格
        theGridMap:function(){
            $.ajax({
                url:'/gridInfo/gridSettingsTreeList',
                dataType:'json',
                success:function(res){
                    var data = res.obj;
                    for(var j=0;j<data.length;j++){
                        var mapInfo = res.obj[j].mapInfo;
                        if(mapInfo != undefined){
                            var arr = mapInfo.split('|');
                            var polygon = new BMap.Polygon(function(){
                                var arr2=[];
                                for(var i=0;i<arr.length;i++){
                                    var type =arr[i].split(',')
                                    var no=new BMap.Point(type[0],type[1]);
                                    arr2.push(no)
                                }
                                return arr2;
                            }(), {strokeColor:'#000',fillColor:'blue', fillOpacity: 0.3,  strokeWeight:1, strokeOpacity:0.5});  //创建多边形
                            map.addOverlay(polygon);
                            polygon.title=data[j].gridName;
                            polygon.tel=data[j].telNo;
                            polygon.name=data[j].directorName;
                            polygon.gridName=data[j].gridUserIdName;
                            polygon.scope=data[j].scope;
                            polygon.location=data[j].location;

                            polygon.addEventListener('click',function(){
                                var title=this.title;
                                var tel=this.tel;
                                var name=this.name;
                                var gridName=this.gridName;
                                var scope=this.scope;
                                var location=this.location;

                                layer.open({
                                    type:1,
                                    title: [title, 'background-color:#2b7fe0;color:#fff;'],
                                    area: ['350px', '720px'],
                                    btn: 0,
                                    content:'<ul>' +
                                    '<li class="clearfx"><img src="/img/newjgy.png" alt="" class="img"><div class="cont"><span class="left">网格名称:</span><span class="right">'+check(title) +'</span></div></li>' +
                                    '<li class="clearfx"><img src="/img/newsq.png" alt="" class="img"><div class="cont"><span class="left">网格电话:</span><span class="right">'+check(tel)+'</span></div></li>' +
                                    '<li class="clearfx"><img src="/img/newjdy.png" alt="" class="img"><div class="cont"><span class="left">网格监督员:</span><span class="right">'+check(name) +'</span></div></li>' +
                                    '<li class="clearfx"><img src="/img/newjgy.png" alt="" class="img"><div class="cont"><span class="left">网格监管员:</span><span class="right">'+check(name) +'</span></div></li>' +
                                    '<li class="clearfx"><img src="/img/newxcy.png" alt="" class="img"><div class="cont"><span class="left">网格巡查员:</span><span class="right">'+check(gridName) +'</span></div></li>' +
                                    '<li class="clearfx"><img src="/img/newlocation.png" alt="" class="img"><div class="cont"><span class="left">网格范围:</span><span class="right">'+check(location) +'</span></div></li>' +
                                    '</ul>'
                                })
                            })
                        }
                    }
                }
            })
        },

//        监控地图
        monitorMap:function(){
            var overlays = [];
            $.ajax({
                url:'/video/selAllVideoDevice',
                dataType:'json',
                success:function(res){
                    var data = res.obj;
                    for(var i=0;i<data.length;i++){
                        if(data[i].gpsAddress !="" && data[i].gpsAddress != undefined){
                            overlays.push(data[i])
                        }
                    }
//                    console.log(overlays)
                    for(var j = 0;j<overlays.length;j++){

                        var lng = overlays[j].gpsAddress.split(',')[0];
                        var lat = overlays[j].gpsAddress.split(',')[1];
                        var point = new BMap.Point(lng,lat)
                        var Icon = '/img/grid/shipinjiankong.png';
                        var con = '<span>'+overlays[j].deviceName+'</span>'
                        //                        point,img,name,id,con,grid,type,title
                        var myCompOverlay = new ComplexCustomOverlay(point,Icon,overlays[j].deviceName,overlays[j].id ,con,'',2,overlays[j].deviceName );
                        map.addOverlay(myCompOverlay);//将标注添加到地图中
                    }
                }
            })
        },

//        企业地图
        enterpriseMap:function(dataType){
            var overlays = [];
            $.ajax({
                url:'/fixForm/selectUnionAll',
                data:{
                    itemType:dataType
                },
                dataType:'json',
                success:function(res){
                    var data = res.datas;
                    for(var i=0;i<data.length;i++){
                        //在建工程项目
                        if(data[i].zuobiao !="" && data[i].zuobiao != undefined){
                            overlays.push(data[i])
                        }
                    }
//                    console.log(overlays)
                    for(var j = 0;j<overlays.length;j++){

                        var lng = overlays[j].zuobiao.split(',')[0];
                        var lat = overlays[j].zuobiao.split(',')[1];
                        var point = new BMap.Point(lng,lat)
                        var type = overlays[j].biaozhi;
                        var status = overlays[j].dengji
//                        var Icon = '/img/grid/shipinjiankong.png';
                        var imgs='';
                        var strname='';
                        if(type=='1'){
                            strname='一般法人单位';
                            if(status=='04'){
                                imgs = '/img/grid/farenyanzhong1.png'
                            }else if(status=='03'){
                                imgs = '/img/grid/yibanzhenggai1.png';
                            }else if(status=='02'){
                                imgs = '/img/grid/farenYiban1.png';
                            }else {
                                imgs = '/img/grid/yibanzhengchang1.png';
                            }
                        }else if(type=='2'){
                            strname='小规模法人单位';
                            if(status=='04'){
                                imgs = '/img/grid/xiaofarenyanzhong1.png'
                            }else if(status=='03'){
                                imgs = '/img/grid/xiaofarenzhenggai1.png';
                            }else if(status=='02'){
                                imgs = '/img/grid/xiguimoYiban1.png';
                            }else {
                                imgs = '/img/grid/xiaofarenzhengchang1.png';
                            }
                        }else if(type=='3'){
                            strname='大型个体工商户';
                            if(status=='04'){
                                imgs = '/img/grid/dagetiyanzhog1.png'
                            }else if(status=='03'){
                                imgs = '/img/grid/dagetizhenggai1.png';
                            }else if(status=='02'){
                                imgs = '/img/grid/daxingYiban1.png';
                            }else{
                                imgs = '/img/grid/dagetizhengchang1.png';
                            }
                        }else if(type=='4'){
                            strname='小型个体工商户';
                            if(status=='04'){
                                imgs = '/img/grid/xiaogetiyanzhong1.png'
                            }else if(status=='03'){
                                imgs = '/img/grid/xiaogetizhenggai1.png';
                            }else if(status=='02'){
                                imgs = '/img/grid/xiaoxingYiban1.png';
                            } else{
                                imgs = '/img/grid/xiaogetizhengchang1.png';
                            }
                        }else if(type=='5'){
                            strname='在建工程项目';
                            if(status=='04'){
                                imgs = '/img/grid/jianshezhongyanzhong1.png'
                            }else if(status=='03'){
                                imgs = '/img/grid/jianshezhongzhenggai1.png';
                            }else if(status=='02'){
                                imgs = '/img/grid/zaijianYiban1.png';
                            }else {
                                imgs = '/img/grid/jianshezhongzhengchang1.png';
                            }
                        }
                        var con = '<span><img src="'+imgs+'" alt=""></span>'


                        //                        point,img,name,id,con,grid,type,title
                        var myCompOverlay = new ComplexCustomOverlay(point,'',type,overlays[j].zhujian ,con,'',3,overlays[j].name );
                        map.addOverlay(myCompOverlay);//将标注添加到地图中
                    }
                }
            })
        },

//        环保设施地图
        environmental:function(){
            var overlays = [];
            $.ajax({
                url:'/TrashDetectionController/trdeSelect',
                data:{
                    page:1,
                    pageSize:10,
                    useFlag:false
                },
                dataType:'json',
                success:function(res){
                    var data = res.obj;
                    for(var i=0;i<data.length;i++){
                        if(data[i].gridLocation !="" && data[i].gridLocation != undefined){
                            data[i].type = 0
                            overlays.push(data[i])
                        }
                    }
//                    console.log(overlays)
                    $.ajax({
                        url:'/TrashMiniatureController/trminSelect',
                        data:{page:1, pageSize:10, useFlag:false},
                        dataType:'json',
                        success:function(res){
                            var datas = res.obj;
                            for(var j=0;j<datas.length;j++){
                                if(datas[j].gridLocation !="" && datas[j].gridLocation != undefined){
                                    datas[j].type = 1
                                    overlays.push(datas[j])
                                }
                            }
                            for(var b = 0;b<overlays.length;b++){

                                var lng = overlays[b].gridLocation.split(',')[0];
                                var lat = overlays[b].v.split(',')[1];
                                var point = new BMap.Point(lng,lat)
                                var Icon=''
                                if(overlays[b].type == 0){
                                    Icon = '../../img/map/oil.png';
                                }else if(overlays[b].type == 1){
                                    Icon = '../../img/map/wei.png';
                                }

                                var con = '<span>'+overlays[j].deviceName+'</span>'
                                //                        point,img,name,id,con,grid,type,title
                                var myCompOverlay = new ComplexCustomOverlay(point,Icon,overlays[j].deviceName,overlays[j].id ,con,'',4,overlays[j].deviceName );
                                map.addOverlay(myCompOverlay);//将标注添加到地图中
                            }

                        }
                    })
                }
            })
        },
    }

</script>
</body>
</html>
